From: Owen Taylor Date: Wed, 19 Nov 2008 23:04:53 +0000 (+0000) Subject: Set a strut to prevent windows under the panel X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~11577 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=840eb62397e48f35186ac1d9b490ff9b0f7fcae1;p=gnome-shell.git Set a strut to prevent windows under the panel Set a strut (a reserved region) at the top of the screen so that windows don't get positioned under the panel. Do this on all workspaces and redo it when the number of workspaces changes. http://bugzilla.gnome.org/show_bug.cgi?id=561297 svn path=/trunk/; revision=63 --- diff --git a/js/ui/panel.js b/js/ui/panel.js index 63f6c2d5c..358503e97 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -2,11 +2,12 @@ const Mainloop = imports.mainloop; -const Shell = imports.gi.Shell; const Clutter = imports.gi.Clutter; +const Meta = imports.gi.Meta; +const Shell = imports.gi.Shell; const Tidy = imports.gi.Tidy; -const Button = imports.ui.button; +const Button = imports.ui.button; const Main = imports.ui.main; const PANEL_HEIGHT = 32; @@ -86,12 +87,42 @@ Panel.prototype = { return true; }); + this._setStruts(); + global.screen.connect('notify::n-workspaces', + function() { + me._setStruts(); + }); + global.stage.add_actor(this._group); this._updateClock(); this._startClock(); }, + // Struts determine the area along each side of the screen that is reserved + // and not available to applications + _setStruts: function() { + let global = Shell.global_get(); + + let struts = [ + new Meta.Strut({ + rect: { + x: 0, + y: 0, + width: global.screen_width, + height: PANEL_HEIGHT + }, + side: Meta.Direction.TOP + }) + ]; + + let screen = global.screen; + for (let i = 0; i < screen.n_workspaces; i++) { + let workspace = screen.get_workspace_by_index(i); + workspace.set_builtin_struts(struts); + } + }, + _startClock: function() { let me = this; // TODO: this makes the clock updated every 60 seconds, but not necessarily on the minute, so it is inaccurate